the problem I ran into was not installing the package in the virtual environment, taking the jieba package as an example
enter python in the virtual environment, and then you can import the package. We thought it was packaged, but it was actually installed in the basic environment.
When
USES conda list to view the packages in the current environment, there is no jieba package.
conda list
forgot the screenshot,,,,
p>
so you need to install jieba using the PIP of the virtual environment.
after confirming wrapping in a virtual environment, switching to a python environment cannot be done by simply typing python commands. Instead, use virtual environment Python, just like the previous PIP.
for example, you now have two files, test.py and test.sh.
test.py
import torch
print(torch.__version__)
test.sh
python test.py
you can see that the PIP version printed in the virtual environment is different from the one printed in the bash script.
so while I installed jieba in the pytorch1.4 environment, the command I used directly was not python in pytorch1.4, but python in the base environment.
summary:
- whether the package to the environment
- used the python interpreter is not the package environment interpreter
there are a lot of ways to do it online, so this is a supplement to what’s possible.
Read More:
- [Solved] ERROR: No matching distribution found for torch-cluster==x.x.x
- [Solved] Ubuntu using blender script error: Numpy cannot be found
- ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
- [Solved] torchvision Error: UserWarning: Failed to load image Python extension: Could not find module
- [Solved] MAC terminal Use ‘CONDA activate’ and ‘CONDA install package_ Error reported by name’ Error
- [Solved] Pycham Error: non zero exit code (2)
- [Solved] Windows10 Pycharm Use Virtual Environment Error: Cannot set up a python SDK
- Pytorch: How to Handle error warning conda.gateways.disk.delete:unlink_or_rename_to_trash(140)
- [Solved] RuntimeError: Numpy is not available (Associated Torch or Tensorflow)
- [Solved] Jupyter Notebook Start Error: Fatal error in launcher: Unable to create process using
- [Solved] Pycharm Use pip Error: Script file ‘D:\Anaconda3\envs\pytorch\Scripts\pip-script.py‘ is not present
- RuntimeError: No HIP GPUs are available [How to Solve]
- Install PyTorch in Anaconda environment
- [Solved] RuntimeError: Error(s) in loading state_dict for BertForTokenClassification
- [Solved] bushi RuntimeError: version_ <= kMaxSupportedFileFormatVersion INTERNAL ASSERT FAILED at /pytorch/caffe2/s
- [Solved] Conda Upgrade Error: PackageNotInstalledError: Package is not installed in prefix.
- Conda Install Library Error: failed with initial frozen solve. Retrying with flexible solve.
- [How to Solve] Reason: Incompatible library version
- [Solved] D2lzh_Pytorch Import error: importerror: DLL load failed while importing
- ModuleNotFoundError: No module named ‘tensorflow.python’ And the pits encountered after installation