Conda setup proxy
When using Conda, if you need to access network resources through a proxy, you can configure the proxy as follows:
-
Open a terminal and run the following command to set up an HTTP proxy:
conda config --set proxy_servers.http http://<代理服务器>:<端口号>
Please replace "<proxy server>" and "<port number>" with your proxy server and port number. For example, if the proxy server you are using is "proxy.example.com" and the port number is "8080", the command should be:
conda config --set proxy_servers.http http://proxy.example.com:8080
-
Run the following command to setup HTTPS proxy:
conda config --set proxy_servers.https https://<代理服务器>:<端口号>
Please replace "<proxy server>" and "<port number>" with the same format as HTTP proxy.
-
Run the following command to test that the proxy settings are correct:
conda info
This will display Conda's configuration information, including proxy settings. If the proxy settings are correct, you should be able to see the proxy server and port number.
Note that if your proxy server requires authentication, you will need to provide a username and password when setting up the proxy. You can set an HTTP proxy with the following command:
conda config --set proxy_servers.http http://<用户名>:<密码>@<代理服务器>:<端口号>
Use the same format to set the HTTPS proxy.
If you need to remove proxy settings from Conda, use the following command:
conda config --remove-key proxy_servers.http
conda config --remove-key proxy_servers.https
This will remove the HTTP and HTTPS proxy settings from Conda's configuration.
example:
conda config --set proxy_servers.http http://127.0.0.1:7890
conda config --set proxy_servers.https http://127.0.0.1:7890
Git
If you need to access the Git repository through a proxy, you can follow the steps below to set up a Git proxy:
- Open a terminal and run the following command to set up an HTTP proxy:
git config --global http.proxy http://<代理服务器>:<端口号>
Please replace "<proxy server>" and "<port number>" with your proxy server and port number. For example, if the proxy server you are using is "proxy.example.com" and the port number is "8080", the command should be:
git config --global http.proxy http://proxy.example.com:8080
- Run the following command to setup HTTPS proxy:
git config --global https.proxy https://<代理服务器>:<端口号>
Please replace "<proxy server>" and "<port number>" with the same format as HTTP proxy.
- If your proxy server requires authentication, you will need to provide a username and password when setting up the proxy. You can set an HTTP proxy with the following command:
git config --global http.proxy http://<用户名>:<密码>@<代理服务器>:<端口号>
Use the same format to set the HTTPS proxy.
- If you need to remove proxy settings from Git, use the following command:
git config --global --unset http.proxy
git config --global --unset https.proxy
This will remove the HTTP and HTTPS proxy settings from Git's configuration.
Note that proxy settings are global and will take effect for all your Git operations.
pip
If you need to access the Python package manager pip through a proxy, you can set up a pip proxy as follows:
- Open a terminal and run the following command to set up an HTTP proxy:
pip config set global.proxy http://<代理服务器>:<端口号>
Please replace "<proxy server>" and "<port number>" with your proxy server and port number. For example, if the proxy server you are using is "proxy.example.com" and the port number is "8080", the command should be:
pip config set global.proxy http://proxy.example.com:8080
- Run the following command to setup HTTPS proxy:
pip config set global.proxy https://<代理服务器>:<端口号>
Please replace "<proxy server>" and "<port number>" with the same format as HTTP proxy.
- If your proxy server requires authentication, you will need to provide a username and password when setting up the proxy. You can set an HTTP proxy with the following command:
pip config set global.proxy http://<用户名>:<密码>@<代理服务器>:<端口号>
Use the same format to set the HTTPS proxy.
- If you need to remove proxy settings from pip, use this command:
pip config unset global.proxy
This will remove the HTTP and HTTPS proxy settings from pip's configuration.
Note that proxy settings are global settings and will take effect for all your pip operations.
"AssertionError: Torch not compiled with CUDA enabled" in spite upgrading to CUDA version
Try checking your CUDA version using
nvcc --version
or
nvidia-smi
Uninstalling the packages and reinstalling it with pip instead solved it for me.
1.conda remove pytorch torchvision torchaudio cudatoolkit
2.pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116
pip cache pit
A commonly used package management tool under Python is pip. Today I encountered such a pit when deploying uWSGI on a server.
The internal routing of uWSGI depends on pcre. After installing it with pip for the first time, there uwsgi
will be a !!! no internal routing support, rebuild with pcre support !!!
warning when running. Well...then we will reinstall uWSGI after installing pcre.
But when reinstalling uWSGI, I found that pip seemed to take out the last compiled uwsgi
file directly from the cache, and did not recompile a copy. So I flipped through the pip manual and said that it can be brought up to cancel the cache. I tried it and it was OK. --no-cache-dir
But where is pip's cache directory?
Google for a long time, some people say that /tmp
in next few files starting with pip, but /tmp
there are no key cache files, only a few compressed packages?
Finally, follow the source code of pip, and you can see a comment in pip.utils.appdirs
it :user_cache_dir
r"""
Return full path to the user-specific cache dir for this application.
"appname" is the name of application.
Typical user cache directories are:
Mac OS X: ~/Library/Caches/<AppName>
Unix: ~/.cache/<AppName> (XDG default)
Windows: C:\Users\<username>\AppData\Local\<AppName>\Cache
On Windows the only suggestion in the MSDN docs is that local settings go
in the `CSIDL_LOCAL_APPDATA` directory. This is identical to the
non-roaming app data dir (the default returned by `user_data_dir`). Apps
typically put cache data somewhere *under* the given dir here. Some
examples:
...\Mozilla\Firefox\Profiles\<ProfileName>\Cache
...\Acme\SuperApp\Cache\1.0
OPINION: This function appends "Cache" to the `CSIDL_LOCAL_APPDATA` value.
"""
The cache directory is actually in the folder home
under the current user, and there is a pip folder inside. After deleting, it will be recompiled when reinstalling..cache
uWSGI
For virtualenv, the cache is also in the current operating user's .cache
.
No module named "Crypto"
pip uninstall crypto pycryptodome
pip
install
pycryptodome
References: